var fs = require('fs');
// 阻塞代码
var data = fs.readFileSync('./test.txt');
console.log(data.toString());
console.log('read txt complete!');

// 非阻塞代码
var callback = function (err, data) {
    if (err) {
        throw new Error('faild to read file!');
    } else {
        console.log(data.toString());
        console.log('read txt complete!');
    }
}
fs.readFile('./test.txt',callback);